/*
 * @Author: your name
 * @Date: 2021-05-31 15:18:06
 * @LastEditTime: 2021-06-07 15:53:54
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \egg-demo\app\controller\goods.js
 */
'use strict';

const { Controller } = require('egg');

class GoodsController extends Controller {
  
  async create() {
    const { ctx } = this;
    const { created_use_uuid, name, intro, deleted } = ctx.request.body;
    const getReqBody = { created_use_uuid, name, intro, deleted }
    console.log('getReqBody',getReqBody)
    const goods = await ctx.model.GoodsGroups.saveNew(getReqBody)
    ctx.helper.renderSuccess(ctx, { data: goods, message: 'ok'})
    // ctx.body = this;
  }

  async list() {
    const { ctx } = this;
    let { page, pageSize, ...filter } = ctx.request.query;
   
    const queryList = await ctx.model.GoodsGroups.queryList( {page, pageSize}, filter)
    ctx.helper.renderSuccess(ctx, { data: queryList})
  }

  async details() {
    const { ctx } = this;
    const { uuid } = ctx.request.query;
    const details = await ctx.model.GoodsGroups.get({uuid})
    ctx.helper.renderSuccess(ctx, { data: details, message: '请求成功'})
  }

}

module.exports = GoodsController;
